<template>
  <div>
    <van-nav-bar title="会员注册" left-text="返回" left-arrow @click-left="() => { $router.push('/login') }" fixed />
    <div style="height: 45px;"></div>
    <van-form @submit="onSubmit">
      <van-cell-group inset>
        <van-field v-model="username" name="username" label="账号" placeholder="请输入账号(必填)"
          :rules="[{ required: true, message: '请输入账号' }]" />
        <van-field v-model="password" type="password" name="password" label="密码" placeholder="请输入密码(必填)"
          :rules="[{ required: true, message: '请输入密码' }]" />
        <van-field v-model="password1" type="password" name="password" label="密码" placeholder="请输入正确密码(必填)"
          :rules="[{ required: true, message: '请输入正确密码' }]" />
        <van-field v-model="username1" name="username" label="姓名" placeholder="请输入姓名(必填)"
          :rules="[{ required: true, message: '请输入姓名' }]" />
        <van-field v-model="tel" name="username" type="tel" label="手机号" placeholder="请输入手机号(必填)"
          :rules="[{ required: true, message: '请输入手机号' }]" />
           <van-field v-model="message" name="username1" type="textarea" label="邮箱" placeholder="请输入邮箱"
        />
        <van-field v-model="message1" label="留言" type="textarea" placeholder="请输入留言" />
      </van-cell-group>
      <div style="margin: 16px;">
        <van-button round block type="primary" native-type="submit">
          注册
        </van-button>
      </div>
    </van-form>

  </div>
</template>

<script setup>
import { ref } from 'vue';
import{registerApi}from '@/api/api'
import { useRouter } from 'vue-router';
const router=useRouter()
    const username = ref('');
    const password = ref('');
        const username1 = ref('');
    const tel = ref('');
    const message = ref('');
    const message1 = ref('');
    const onSubmit = () => {
      console.log( username.value, password.value);
      registerApi(username.value, password.value).then(res=>{
        console.log(res);
router.push('/login')
      })
    };
</script>

<style lang="scss" scoped></style>